package hu.issue.framework.web.controller;

import hu.issue.framework.web.validation.ErrorMessages;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class SimpleFormController extends AbstractFormController {

	@Override
	protected String handleSubmission(final HttpServletRequest request, final HttpServletResponse response, final ErrorMessages messages) throws Exception {
		if (handleSubmissionInternal(request, response, messages)) {
			return getSuccessView();
		} else {
			return handleGet(request, response);
		}
	}

	protected String getSuccessView() {
		return getControllerName() + "-success.jsp";
	}

	protected abstract boolean handleSubmissionInternal(final HttpServletRequest request, final HttpServletResponse response, ErrorMessages messages) throws Exception;

}
